/*
  launchduino.c - Partial implementation of the Wiring API for the MSP430G2231.
  Part of Launchduino - http://www.launchduino.cc/

  Copyright (c) 2010 R.N

  Modified 23 January 2011 by R.N.
*/
#include "launchduino.h"

void pinMode(uint8_t pin, uint8_t mode)
{
    if (OUTPUT == mode) {
        P1DIR |= (0x01 << pin);
    } else {
        P1DIR &= ~(0x01 << pin);
    }
}

void digitalWrite(uint8_t pin, uint8_t val)
{
    if (HIGH == val) {
        P1OUT |= (0x01 << pin);
    } else {
        P1OUT &= ~(0x01 << pin);
    }
}

int digitalRead(uint8_t pin)
{
    //digitalRead function is not implemented.
    return 0;
}

void init(void)
{
    WDTCTL = WDTPW + WDTHOLD;  // Stop watchdog timer

    BCSCTL1 = CALBC1_1MHZ;
    DCOCTL = CALDCO_1MHZ;
}
